﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.codeplex.com/MSSqlSchemaDoc"
  xmlns="http://www.codeplex.com/MSSqlSchemaDoc"
  attributeFormDefault="unqualified"
  elementFormDefault="qualified">

  <xs:include schemaLocation="ColumnCollectionType.xsd" />
  <xs:include schemaLocation="IndexCollectionType.xsd" />
  <xs:include schemaLocation="ForeignKeyCollectionType.xsd" />

  <xs:element name="Table">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="UsesAnsiNulls" type="xs:boolean" />
        <xs:element name="Columns" type="ColumnCollectionType" />
        
        <xs:element name="Triggers">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" maxOccurs="unbounded" name="Trigger">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Events">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element maxOccurs="unbounded" name="TriggerEvent">
                            <xs:complexType>
                              <xs:attribute name="Name" use="required">
                                <xs:simpleType>
                                  <xs:restriction base="xs:string">
                                    <xs:enumeration value="UPDATE" />
                                    <xs:enumeration value="INSERT" />
                                    <xs:enumeration value="DELETE" />
                                  </xs:restriction>
                                </xs:simpleType>
                              </xs:attribute>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="IsInsteadOf" type="xs:boolean" />
                  </xs:sequence>
                  <xs:attribute name="Name" type="xs:string" use="required" />
                  <xs:attribute name="Schema" type="xs:string" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="Indexes" type="IndexCollectionType" />

        <xs:element name="ForeignKeys" type="ForeignKeyCollectionType" />

      </xs:sequence>
      <xs:attribute name="Name" type="xs:string" use="required" />
      <xs:attribute name="Schema" type="xs:string" use="required" />
    </xs:complexType>
  </xs:element>

</xs:schema>